package com.xzy.mybatis.cipher.config;

import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import com.xzy.mybatis.cipher.annotation.EnableMybatisCipher;
import com.xzy.mybatis.cipher.support.DatasourceHolder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author xzy.xiao
 * @since 2025/1/13  17:26
 */
@Configuration
@MapperScan(basePackages = {"com.xzy.mybatis.cipher.mapper"})
@EnableMybatisCipher(scanPackages = {"com.xzy.mybatis.cipher.entity"})
public class MybatisConfig {
    @Bean
    public DatasourceHolder datasourceHolder() {
        return DynamicDataSourceContextHolder::peek;
    }
}
